﻿<%@ Page Language="C#" EnableEventValidation="false" ValidateRequest="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace=" System.Collections" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Import Namespace="TarreOA.TarreOAModels" %>
<%@ Import Namespace="TarreOA.TarreOABLL" %>
<script runat="server">

    protected void BtnSend_Click(object sender, EventArgs e)
    {
        try
        {
            if (ViewState["thl_Id"] != null)
            {
                thl_Id = (int)ViewState["thl_Id"];
            }
            User curLoginUser = (User)Session["user"];
            string talkContent = this.TextBox1.Text;
            UserTalkContent utc = UserTalkContent.instance();
            string target = Request.Params.GetValues(this.DdlTalkTarget.ClientID)[0];
            string color = Request.Params.GetValues("selectColor")[0];
            string action = Request.Params.GetValues("addimg")[0];
            string imgSource = "";
            string imgTitle = "";
            if (!"".Equals(action.Trim()))
            {
                imgSource = action.Split(',')[0];
                imgTitle = action.Split(',')[1];
                action = "<img align='bottom' src='../images/addimgs/" + imgSource + ".gif' title='" + imgTitle + "' />";
            }
            if (utc.TalkContents["Talk" + thl_Id.ToString()] != null)
            {
                List<string> contentList = (List<string>)utc.TalkContents["Talk" + thl_Id.ToString()];
                contentList.Add("[<font color=''><b>" + curLoginUser.UserName + "</b></font>]<font color='Purple' style='font-size:12px'><b>" +
                    action + "</b></font>对<b>" + target + "</b>说:<font color='"
                    + color + "'>" + @talkContent + "</font><font color='#a9a9a9'>[" + DateTime.Now.ToString() + "]</font>");
                utc.TalkContents["Talk" + thl_Id.ToString()] = contentList;
            }
            this.TextBox1.Text = "";
            this.TextBox1.Focus();
            ViewState["thl_Id"] = thl_Id;
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }

    private int thl_Id;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString.Get("thl_id") != null)
            {
                thl_Id = int.Parse(Request.QueryString.Get("thl_id"));
                this.TextBox1.Attributes.Add("onkeydown", "subForm()");
                ViewState["thl_Id"] = thl_Id;
                Session["thl_id"] = thl_Id;
            }
        }
        this.TextBox1.Focus();
    }

    protected void BtnExit_Click(object sender, EventArgs e)
    {
        if (ViewState["thl_Id"] != null)
        {
            thl_Id = (int)ViewState["thl_Id"];
        }
        Response.Redirect("OutTalk.aspx?thl_id=" + thl_Id);
    }

    protected void Btnexitt_ServerClick(object sender, EventArgs e)
    {
        Session.Abandon();
    }
    
    
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
    <script type="text/javascript" src="../js/UserTalkHouse.js"></script>
    <link rel="Stylesheet" type="text/css" href="../Styles/right_style.css" />
    <script type="text/javascript" src="../Scripts/jquery.ui/js/jquery.js"></script>
    <style type="text/css"> 
        <!--
        html{ scrollbar-base-color: #dbecf8; scrollbar-arrow-color: #2a8ed1; scrollbar-track-color: #bdddf2; scrollbar-3dlight-color: #2886c5; scrollbar-darkshadow-color: #2886c5;
        scrollbar-face-color: #dbecf8; scrollbar-shadow-color: #dbecf8;  }
        -->
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div class="chatroom_bottom">
        <div class="chatroom_bottom_top">
            图案：
            <select name="addimg" id="addimg">
                <option selected="selected" value="">不贴图</option>
                <option value="0,招手女孩">招手女孩</option>
                <option value="1,无忧女孩">无忧女孩</option>
                <option value="11,欢迎女孩">欢迎女孩</option>
                <option value="2,欢迎男孩">欢迎男孩</option>
                <option value="3,高兴男孩">高兴男孩</option>
                <option value="26,高兴女孩">高兴女孩</option>
                <option value="4,月亮女孩">月亮女孩</option>
                <option value="5,思念女孩">思念女孩</option>
                <option value="6,信件">信件</option>
                <option value="7,爱心">爱心</option>
                <option value="8,电话">电话</option>
                <option value="9,下跪">下跪</option>
                <option value="10,非常正确">非常正确</option>
                <option value="12,为什么呀">为什么呀</option>
                <option value="13,口水横流">口水横流</option>
                <option value="14,闹钟">闹钟</option>
                <option value="15,哭泣女孩">哭泣女孩</option>
                <option value="16,可爱天使">可爱天使</option>
                <option value="17,狗狗">狗狗</option>
                <option value="18,狡黠女孩">狡黠女孩</option>
                <option value="19,大吃一惊">大吃一惊</option>
                <option value="20,爱心">爱心</option>
                <option value="21,炸弹">炸弹</option>
                <option value="22,水雷">水雷</option>
                <option value="23,千夫指">千夫指</option>
                <option value="24,停止">停止</option>
                <option value="25,水果女孩">水果女孩</option>
            </select>
            <asp:DropDownList ID="DdlTalkTarget" runat="server" Width="76px">
                <asp:ListItem Value="大家">所有人</asp:ListItem>
            </asp:DropDownList>
            &nbsp;字体颜色：
            <select id="selectColor" name="selectColor">
                <option selected="selected" style="color: #000000" value="#000000">黑色</option>
                <option style="color: #7ec0ee" value="#7EC0EE">淡蓝</option>
                <option style="color: #0088ff" value="#0088FF">海蓝</option>
                <option style="color: #0000ff" value="#0000FF">草蓝</option>
                <option style="color: #000088" value="#000088">深蓝</option>
                <option style="color: #8800ff" value="#8800FF">蓝紫</option>
                <option style="color: #ab82ff" value="#AB82FF">紫色</option>
                <option style="color: #ff88ff" value="#FF88FF">紫金</option>
                <option style="color: #ff00ff" value="#FF00FF">红紫</option>
                <option style="color: #ff0088" value="#FF0088">玫红</option>
                <option style="color: #ff0000" value="#FF0000">大红</option>
                <option style="color: #f4a460" value="#F4A460">棕色</option>
                <option style="color: #cc9999" value="#CC9999">浅褐</option>
                <option style="color: #888800" value="#888800">卡其</option>
                <option style="color: #888888" value="#888888">铁灰</option>
                <option style="color: #cccccc" value="#CCCCCC">古黑</option>
                <option style="color: #90e090" value="#90E090">绿色</option>
                <option style="color: #008800" value="#008800">橄榄</option>
                <option style="color: #008888" value="#008888">灰蓝</option>
            </select>
            <input id="Checkbox2" onclick="alterTalkContent('Checkbox2')" type="checkbox" runat="server" />自动滚屏
        </div>
        <div class="chatroom_bottom_cont">
            您也可以Ctrl+Enter发送息，不支持中文繁体字。</div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <div class="chatroom_bottom_bot">
                    <span class="chat_text">
                        <asp:TextBox ID="TextBox1" runat="server" Height="30px" TextMode="MultiLine" Width="600px"></asp:TextBox></span>
                    <span class="chat_button">
                        <asp:Button ID="BtnSend" runat="server" Text="发送" OnClick="BtnSend_Click" CssClass="button_01" />
                    </span><span class="chat_button">
                        <asp:Button ID="BtnExit" runat="server" OnClick="BtnExit_Click" OnClientClick="javascript:document.body.onbeforeunload = ''"
                            Text="退出" CssClass="button_01" />
                    </span>
                    <input id="Btnexitt" type="button" value="button" runat="server" style="display: none"
                        onserverclick="Btnexitt_ServerClick" />
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
        </div>
        <script type="text/javascript" language="javascript">
            $(window).unload(function () {
                alert('您将退出聊天室！');
                document.getElementById("BtnExit").click();
                if (event.clientX > document.body.clientWidth && event.clientY < 0 || event.altKey) {
                    document.getElementById("Btnexitt").click();
                }
            });
            window.onbeforeunload = function () {
                alert('您将退出聊天室！');
                document.getElementById("BtnExit").click();
                if (event.clientX > document.body.clientWidth && event.clientY < 0 || event.altKey) {
                    document.getElementById("Btnexitt").click();
                }
            }   
        </script>
    </form>
</body>
</html>
